package com.newjiabo.web.controller.ski;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.newjiabo.common.annotation.Log;
import com.newjiabo.common.core.controller.BaseController;
import com.newjiabo.common.core.domain.AjaxResult;
import com.newjiabo.common.enums.BusinessType;
import com.newjiabo.ski.domain.SkiCameramanRequestNote;
import com.newjiabo.ski.service.ISkiCameramanRequestNoteService;
import com.newjiabo.common.utils.poi.ExcelUtil;
import com.newjiabo.common.core.page.TableDataInfo;

/**
 * 摄影师申请单
 * Controller
 *
 * @author CaoMengHui
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/system/note")
@Api(tags = "后台;摄影师申请单")
public class SkiCameramanRequestNoteController extends BaseController {
    @Resource
    private ISkiCameramanRequestNoteService skiCameramanRequestNoteService;

    /**
     * 查询摄影师申请单列表
     */
    @ApiOperation(value = "查询摄影师申请单列表")
    @PreAuthorize("@ss.hasPermi('ski:note:list')")
    @GetMapping("/list")
    public TableDataInfo list(SkiCameramanRequestNote skiCameramanRequestNote) {
        startPage();
        List<SkiCameramanRequestNote> list = skiCameramanRequestNoteService.selectSkiCameramanRequestNoteList(skiCameramanRequestNote);
        return getDataTable(list);
    }

    /**
     * 导出摄影师申请单列表
     */
    @ApiOperation(value = "导出摄影师申请单列表")
    @PreAuthorize("@ss.hasPermi('ski:note:export')")
    @Log(title = "摄影师申请单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SkiCameramanRequestNote skiCameramanRequestNote) {
        List<SkiCameramanRequestNote> list = skiCameramanRequestNoteService.selectSkiCameramanRequestNoteList(skiCameramanRequestNote);
        ExcelUtil<SkiCameramanRequestNote> util = new ExcelUtil<SkiCameramanRequestNote>(SkiCameramanRequestNote.class);
        util.exportExcel(response, list, "摄影师申请单数据");
    }

    /**
     * 获取摄影师申请单详细信息
     */
    @ApiOperation(value = "获取摄影师申请单详细信息")
    @PreAuthorize("@ss.hasPermi('ski:note:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(skiCameramanRequestNoteService.selectSkiCameramanRequestNoteById(id));
    }

    /**
     * 新增摄影师申请单
     */
    @ApiOperation(value = "新增摄影师申请单")
    @PreAuthorize("@ss.hasPermi('ski:note:add')")
    @Log(title = "摄影师申请单 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SkiCameramanRequestNote skiCameramanRequestNote) {
        return toAjax(skiCameramanRequestNoteService.insertSkiCameramanRequestNote(skiCameramanRequestNote));
    }

    /**
     * 修改摄影师申请单
     */
    @ApiOperation(value = "修改摄影师申请单")
    @PreAuthorize("@ss.hasPermi('ski:note:edit')")
    @Log(title = "摄影师申请单 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SkiCameramanRequestNote skiCameramanRequestNote) {
        return toAjax(skiCameramanRequestNoteService.updateSkiCameramanRequestNote(skiCameramanRequestNote));
    }

    /**
     * 删除摄影师申请单
     */
    @ApiOperation(value = "删除摄影师申请单")
    @PreAuthorize("@ss.hasPermi('ski:note:remove')")
    @Log(title = "摄影师申请单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(skiCameramanRequestNoteService.deleteSkiCameramanRequestNoteByIds(ids));
    }

    @ApiOperation(value = "审核申请单")
    @PostMapping(value = "/audit/{noteId}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noteId", value = "申请单id", required = true, dataType = "String", paramType = "path"),
            @ApiImplicitParam(name = "auditStatus", value = "审核状态", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "auditorRemarks", value = "审核员备注", required = false, dataType = "String", paramType = "form")
    })
    public AjaxResult audit(@PathVariable @NotNull(message = "申请单id不能为空！")String noteId,
                            @NotNull(message = "审核状态不能为空！")String auditStatus,
                            String auditorRemarks){
        return toAjax(skiCameramanRequestNoteService.audit(noteId,auditStatus,auditorRemarks));
    }

}
